#define  _CRT_SECURE_NO_WARNINGS 1
#pragma once
#include<iostream>
#include<assert.h>
using namespace std;
namespace wz {
	class string {
	public:
		using iterator = char*;
		using const_iterator = const char*;
		string(const char* str="");
		string(const string& s);
		void reserve(size_t n);
		const char* c_str()const {
			return _str;
		}
		void push_back(char ch);
		void append(const char* str);
		void insert(size_t pos, char ch);
		void insert(size_t pos, const char* str);
		void erase(size_t pos,size_t len = npos);
		size_t find(char ch, size_t pos = 0);
		size_t find(const char* str, size_t pos = 0);
		void operator+=(const char* str) {
			append(str);
		}
		void operator+=(char ch) {
			push_back(ch);
		}
		char& operator[](size_t i) {
			assert(i < _size);
			return _str[i];
		}
		const char& operator[](size_t i)const {
			assert(i < _size);
			return _str[i];
		}
		void clear() {
			_str[0] = '\0';
			_size = 0;
		}
		size_t size() {
			return _size;
		}
		size_t capacity() {
			return _capacity;
		}
		iterator begin() {
			return _str;
		}
		const_iterator begin()const {
			return _str;
		}
		iterator end() {
			return _str + _size;
		}
		const_iterator end()const {
			return _str + _size;
		}
		void swap(string& s);
		string substr(size_t pos, size_t len = npos);
		~string();
	private:
		char* _str;
		size_t _size;
		size_t _capacity;
	public:
		const static size_t npos;
	};
	void swap(string& s1, string& s2);
	bool operator==(const string& s1, const string& s2);
	bool operator>=(const string& s1, const string& s2);
	bool operator>(const string& s1, const string& s2);
	bool operator<=(const string& s1, const string& s2);
	bool operator<(const string& s1, const string& s2);
	bool operator!=(const string& s1, const string& s2);
}
